package com.zly.lab.blog.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zly.lab.blog.entity.Article;
import com.zly.lab.blog.mapper.ArticleMapper;
import com.zly.lab.blog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleMapper articleMapper;

    @Override
    public PageInfo<Article> getArticlePage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Article> articlePage = articleMapper.getArticlePage();
        PageInfo<Article> articlePageInfo = new PageInfo<>(articlePage);
        return articlePageInfo;
    }

    @Override
    public Article getArticleById(Integer articleId) {
        return articleMapper.getArticleById(articleId);
    }
}
